#import <UIKit/UIKit.h>
#import "ZLTextHighlight.h"

NS_ASSUME_NONNULL_BEGIN

@interface ZLTextLayout : NSObject
@property (nonatomic, strong) NSMutableArray<ZLTextHighlight *> *highlights;
@property (nonatomic, strong) NSLayoutManager *layoutManager;

@property (nonatomic, strong) NSTextContainer *textContainer;
/// 原始文本
@property (nonatomic, copy, readonly) NSAttributedString *text;

/// 文本容器大小
@property (nonatomic, assign) CGSize size;

/// 是否需要更新布局
@property (nonatomic, assign) BOOL needsUpdateLayout;

/// 当前高亮的文本范围
@property (nonatomic, strong, readonly, nullable) ZLTextHighlight *highlightRange;

/// 初始化方法
- (instancetype)initWithText:(NSAttributedString *)text size:(CGSize)size;

/// 添加高亮文本
- (void)addHighlight:(ZLTextHighlight *)highlight;

/// 移除高亮文本
- (void)removeHighlight:(ZLTextHighlight *)highlight;

/// 移除所有高亮文本
- (void)removeAllHighlights;

/// 处理点击事件
- (void)touchPoint:(CGPoint)point;

/// 获取文本绘制大小
- (CGSize)textBoundingSize;

/// 绘制文本
- (void)drawInContext:(CGContextRef)context;

@end

NS_ASSUME_NONNULL_END 
